$(document).ready(function() {
	
        /**
		 * 下面是进行插件初始化 你只需传入相应的键值对
		 */
        $('#defaultForm').bootstrapValidator({
            message: 'This value is not valid',
            feedbackIcons: {/* 输入框不同状态，显示图片的样式 */
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {/* 验证 */
                username: {/* 键名username和input name值对应 */
                    message: 'The username is not valid',
                    validators: {
                        notEmpty: {/* 非空提示 */
                            message: '用户名不能为空'
                        },
                        stringLength: {/* 长度提示 */
                            min: 6,
                            max: 30,
                            message: '用户名长度必须在6到30之间'
                        }/* 最后一个没有逗号 */
                    }
                },
                password: {
                    message:'密码无效',
                    validators: {
                        notEmpty: {
                            message: '密码不能为空'
                        },
                        stringLength: {
                            min: 6,
                            max: 30,
                            message: '用户名长度必须在6到30之间'
                        }
                    }
                },
                email: {
                    validators: {
                        notEmpty: {
                            message: 'The email address is required and can\'t be empty'
                        },
                        emailAddress: {
                            message: 'The input is not a valid email address'
                        }
                    }
                }
            }
        });
    });



function submitform(){
	
    $.ajax({
        url:ctx +　"/manag/user/updatePhoto",
        type:"post",
        data:$('#registrationForm').serialize(),
        dataType : "json",
        success:function(data){
        	if(data.code > 0){
        		location.href = ctx +　"/console/index";
        		parent.location.reload();
        	}else{
        		toastr.error(data.msg);
        	}
        },
        error:function(e){
        	toastr.error('系统错误');
        }
    });        

    return false;
}


function validateForm(){
	
    var form = new FormData(document.getElementById("userForm"));
    
    var src = $('.avatar-src').val();
    var data = $('.avatar-data').val();
    
    //console.log(src);
    //console.log(data);
    
    $.ajax({
        url:ctx +　"/pic/uploadCutImage",
        type:"post",
        data:form,
        processData:false,
        contentType:false,
        dataType : "json",
        success:function(data){
          	$('#userImg').attr('src', tracker_server + data.path);
          	$('#avatar-modal').modal('hide');
          	
          	$('#photo').val(data.path);
        },
        error:function(e){
            alert("错误！！");
        }
    });        
    return false;
}





